#ifndef TFRMCALIBUNIT_H
#define TFRMCALIBUNIT_H

#include <QWidget>
#include <QTimer>
#include "tlrstructmodel.h"
#include "tlr.h"

namespace Ui {
class TFrmCalibUnit;
}

class TFrmCalibUnit : public QWidget
{
    Q_OBJECT

public:
    explicit TFrmCalibUnit(QWidget *parent = nullptr);
    ~TFrmCalibUnit();

    //重置
    void reset(const TLRCalib &calib);
    //设置ID
    void setID(int id);

private:
    Ui::TFrmCalibUnit *ui;
    //校准信息
    TLRCalib m_calib;
    //定时读取定时器
    QTimer *m_tmRd = nullptr;
    //采样测量值
    QList<s64> m_meas_samples;
    //目标值
    s64 m_destVal = 0;
    //原始校准值
    s64 m_originCalibVal = 0;
    //校准值是否初始化读取成功
    bool m_calibValInit = false;
    //序号
    int m_id;

    //比例校准
    void calib_ratio();
    //偏移校准
    void calib_offset();
    //7022E校准
    void calib_7022();

private slots:
    //校准开始/停止点击
    void slotBtnStartClicked();
    void slotBtnStopClicked();
    //结构体数据更新
    void slotStructDataUpdate(int sta,int struct_sta,int len,const QByteArray &data);
    //定时读取
    void slotRd();
    //校准开始/结束
    void slotCalibStarted(int id);
    void slotCalibStoped();

};

#endif // TFRMCALIBUNIT_H
